package com.guigu.liuzhireng.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.liuzhireng.mapper.TechnologyMapper;
import com.guigu.liuzhireng.pojo.PageVo;
import com.guigu.liuzhireng.pojo.Technology;
import com.guigu.liuzhireng.service.TechnologyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TechnologyServiceImpl implements TechnologyService {

    @Autowired
    TechnologyMapper technologyMapper;

    @Override
    public int insert(Technology technology) {
        return technologyMapper.insert(technology);
    }

    @Override
    public int update(Technology technology) {
        return technologyMapper.updateByPrimaryKeySelective(technology);
    }

    @Override
    public int delete(Integer tid) {
        return technologyMapper.deleteByPrimaryKey(tid);
    }

    @Override
    public PageVo<Technology> Page(Technology technology, int num, int size) {
        PageHelper.startPage(num,size);
        List<Technology> list = technologyMapper.TechnologyAll(technology);
        PageInfo<Technology> pageInfo = new PageInfo<>(list);

        PageVo<Technology> pageVo = new PageVo<>();
        pageVo.setTotal(pageInfo.getTotal());
        pageVo.setRows(pageInfo.getList());
        return pageVo;
    }
}
